Prevent zero from being passed to array_chunk() #686
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type of pull request
About
Passing a zero (0) value to the
array_chunk()
function causes an error, and in rare cases, a PDF XRef object may be added to a document with an "empty"/W [0 0 0]
command. In RawDataParser.php this would cause the$rowlen
variable to be set to zero and cause an error.Add a simple check to return an empty array in this case. Resolves #679.
It is very difficult to create a unit test for this error as it requires a PDF to be generated with "empty" sections with the specific
/W [0 0 0]
command. As the error occurs at a point when the entire document is being considered, we can't just feed PdfParser some test PDF code that's a subsection of a full document. The sample PDF given by the reporter of issue #679 contained personal info that we cannot include in PdfParser and they did not know how to generate a similar file. It is hoped we can merge this PR without a unit test added, since it is, at it's core, just a check for a zero value which should have been in the code already. :)Thanks to @KeanuTang for the initial analysis and provided code solution, with which I built this PR.
Checklist for code / configuration changes
In case you changed the code/configuration, please read each of the following checkboxes as they contain valuable information:
Code changes without any tests are likely to be rejected. If you dont know how to write tests, no problem, tell us upfront and we may add them ourselves or discuss other ways.
fixes #1234
to outline that you are providing a fix for the issue#1234
.